<template>
  <svg :class="svgClass" v-bind="$attrs" :style="{ color: color }">
    <use :xlink:href="iconName"></use>
  </svg>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { isExternal } from '../utils/tools'
const props = defineProps({
  name: {
    type: String,
    required: true
  },
  color: {
    type: String,
    default: ''
  },
  iconClass: {
    type: String,
    required: true
  },
  className: {
    type: String,
    default: ''
  }
})
const isExternals = () => {
  return isExternal(props.iconClass)
}
const iconName = computed(() => `#icon-${props.iconClass}`)
const svgClass = computed(() => {
  //   if (props.name) return 'svg-icon ' + props.name;
  if (props.name) return `svg-icon icon-${props.className}`
  return 'svg-icon'
})
</script>
<style scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: middle;
}
</style>
